import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/login',
      component: () => import('@/views/Login/index.vue'),
      meta: {
        title: '登录',
      },
    },
    {
      path: '/login/callback',
      component: () => import('@/views/Login/bindMobile.vue'),
      meta: {
        title: 'qq登录-绑定手机号',
      },
    },
    {
      path: '/register',
      component: () => import('@/views/Register/index.vue'),
      meta: {
        title: '注册',
      },
    },
    {
      path: '/login/protocol',
      component: () => import('@/views/Login/protocol.vue'),
      meta: {
        title: '用户协议',
      },
    },
    {
      path: '/', // 布局layout组件
      component: () => import('@/views/layout/index.vue'),
      redirect: '/home',
      children: [
        // 首页
        {
          path: 'home',
          component: () => import('@/views/home/index.vue'),
          meta: {
            title: '首页',
          },
        },
        // 健康百科
        {
          path: 'article',
          component: () => import('@/views/article/index.vue'),
          meta: {
            title: '健康百科',
          },
        },
        // 消息中心
        {
          path: 'notify',
          component: () => import('@/views/notify/index.vue'),
          meta: {
            title: '消息中心',
          },
        },
        // 个人中心
        {
          path: 'user',
          component: () => import('@/views/user/index.vue'),
          meta: {
            title: '个人中心',
          },
        },
      ],
    },
    {
      path: '/user/patient',
      component: () => import('@/views/user/PatientInfo.vue'),
      meta: { title: '家庭档案' },
    },
    {
      path: '/consult/fast',
      component: () => import('@/views/consult/ConsultFast.vue'),
      meta: { title: '极速问诊' },
    },
    {
      path: '/consult/dep',
      component: () => import('@/views/consult/ConsultDep.vue'),
      meta: { title: '选择科室' },
    },
    {
      path: '/consult/illness',
      component: () => import('@/views/consult/ConsultIllness.vue'),
      meta: { title: '病情描述' },
    },
    // 支付
    {
      path: '/consult/pay',
      component: () => import('@/views/consult/ConsultPay.vue'),
      meta: {
        title: '问诊支付',
      },
    },
    // 问诊室
    {
      path: '/room',
      component: () => import('@/views/room/index.vue'),
      meta: { title: '问诊室' },
    },
    // 问诊订单
    {
      path: '/user/consult',
      component: () => import('@/views/user/ConsultOrder.vue'),
      meta: { title: '问诊记录 ' },
    },
    // 问诊订单详情
    {
      path: '/user/consult/:id',
      component: () => import('@/views/user/ConsultDetail.vue'),
      meta: { title: '问诊详情' },
    },
    // 药品支付
    {
      path: '/medicine/pay',
      component: () => import('@/views/medicine/OrderPay.vue'),
      meta: { title: '药品支付' },
    },
    // 地址管理
    {
      path: '/user/address',
      component: () => import('@/views/user/Addresss/index.vue'),
      meta: { title: '地址管理' },
    },
    // 药品支付结果
    {
      path: '/medicine/pay/result',
      component: () => import('@/views/medicine/OrderPayResult.vue'),
      meta: { title: '药品支付结果' },
    },
    // 药品订单详情
    {
      path: '/medicine/:id',
      component: () => import('@/views/medicine/OrderDetail.vue'),
      meta: { title: '药品订单详情' },
    },
    // 物流详情
    {
      path: '/medicine/express/:id',
      component: () => import('@/views/medicine/OrderExpress.vue'),
      meta: { title: '物流详情' },
    },
    // 处方列表
    {
      path: '/user/prescription',
      component: () => import('@/views/user/PrescriptionList.vue'),
      meta: { title: '我的处方' },
    },
    // 药品订单列表
    {
      path: '/medicine/order',
      component: () => import('@/views/medicine/index.vue'),
      meta: { title: '药品订单列表' },
    },
    // 404
    {
      path: '/404',
      component: () => import('@/views/404/index.vue'),
      meta: { title: '404' },
    },
    {
      path: '/:pathMatch(.*)*',
      redirect: '/404',
    },
  ],
})

export default router
